// TestTTSDlg.h : header file
//

#if !defined(AFX_TESTTTSDLG_H__785D8B2D_50E9_43F5_9FBC_98506583E6B0__INCLUDED_)
#define AFX_TESTTTSDLG_H__785D8B2D_50E9_43F5_9FBC_98506583E6B0__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "sapi.h"
#include "vector"
using namespace std;

class CTestTTSDlgAutoProxy;

/////////////////////////////////////////////////////////////////////////////
// CTestTTSDlg dialog

class CTestTTSDlg : public CDialog
{
	DECLARE_DYNAMIC(CTestTTSDlg);
	friend class CTestTTSDlgAutoProxy;

// Construction
public:
	CTestTTSDlg(CWnd* pParent = NULL);	// standard constructor
	virtual ~CTestTTSDlg();

// Dialog Data
	//{{AFX_DATA(CTestTTSDlg)
	enum { IDD = IDD_TESTTTS_DIALOG };
	CComboBox	m_cbRate;
	CComboBox	m_cbVoice;
	CListCtrl	m_listAt;
	CString	m_strWord;
	CString	m_strName;
	CString	m_strFile;
	BOOL	m_bChkHide;
	BOOL	m_bChkMute;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CTestTTSDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	CTestTTSDlgAutoProxy* m_pAutoProxy;
	HICON m_hIcon;
	enum{MAX_BUF_LEN = 1024};
	enum EVoiceThreadStatus{EStatusStart, EStatusEnd, EStatusPause};
	enum{ITEM_NAME_IDX, ITEM_VOICE_IDX, ITEM_MUTE_IDX, ITEM_HIDE_IDX};
	vector<CString> m_vWord;
	vector<CString> m_vName;
	int m_nCurReadIdx;
	CString m_strCurPath;
	CString m_strTmpFile;
	int m_nCurPos;
	int m_nEndPos;


	CLSID m_CLSID_SpVoice;    // class ID for the SAPI SpVoice object
	LPDISPATCH m_pDisp;       // dispatch interface for the class
	ISpeechVoice m_Voice;     // use the MFC Class Wizard generated 
	ISpeechObjectTokens m_VoiceList;

	EVoiceThreadStatus m_eStatus;

	BOOL CanExit();
	void InitWordsFromFile(const char* szFileName);
	void InitVoice();
	CString GetTrueWord(const CString &strWord);
	void TrimWord(CString &strWord);
	void InitNameList();
	void InitEditShow();
	void InitCbVoice();

	void PosMove();
	void UpdatePos();
	void TextFocusToPos();

	CString GetNameListItem(const CString &strName, int nIdx);

	void SetStatus(EVoiceThreadStatus eStatus){m_eStatus = eStatus;};
	EVoiceThreadStatus GetStatus(){return m_eStatus;};

	int GetCurSelListItem();
	int GetCbVoiceIdx(const CString &strVoice);

	// Generated message map functions
	//{{AFX_MSG(CTestTTSDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnClose();
	virtual void OnOK();
	virtual void OnCancel();
	afx_msg void OnButtonTest();
	afx_msg void OnButtonStart();
	afx_msg void OnButtonPause();
	afx_msg void OnButtonStop();
	afx_msg void OnClickListActor(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnSelchangeComboVoice();
	afx_msg void OnCheckHide();
	afx_msg void OnCheckMute();
	afx_msg void OnButtonBrows();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

public:
	bool IsThreadEnd(){return m_eStatus == EStatusEnd;};
	bool IsThreadPause(){return m_eStatus == EStatusPause;};
	void Read();
	
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_TESTTTSDLG_H__785D8B2D_50E9_43F5_9FBC_98506583E6B0__INCLUDED_)
